<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="userInteraction.*" %>
<%@page import="java.util.ArrayList"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="updateUser" class="userInteraction.updateUserInformation"></jsp:useBean>
<jsp:useBean id="readUser" class="userInteraction.readUserInformation"></jsp:useBean>
<jsp:setProperty property="*" name="readUser"/>
<jsp:setProperty property="*" name="updateUser"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
	<% 
	readUserInformation userInfo =new readUserInformation();
	ArrayList<String> returnedUser =new ArrayList<String>();
	returnedUser=userInfo.readUserByEmail(session.getAttribute("loggedIn").toString());
	%>
<body>
	<input type="hidden" name="firstName" id="hFirstName" value="<% out.println(returnedUser.get(0)); %>" />
	<input type="hidden" name="lastName" id="hLastName" value="<% out.println(returnedUser.get(1)); %>" />
	<input type="hidden" name="city" id="hCity" value="<% out.println(returnedUser.get(2)); %>" />
	<input type="hidden" name="phoneNumber" id="hPhoneNumber" value="<% out.println(returnedUser.get(3)); %>" />
	<input type="hidden" name="password" id="hPassword" value="<% out.println(returnedUser.get(4)); %>" />
	<input type="hidden" name="emailAddress" id="hEmailAddress" value="<% out.println(session.getAttribute("loggedIn")); %>" />

<%
updateUserInformation user = new updateUserInformation();
if(request.getParameter("firstName")!=null && request.getParameter("lastName") != null)
{
	if(user.updateInformation(request.getParameter("firstName"),request.getParameter("lastName"),returnedUser.get(3),returnedUser.get(2),returnedUser.get(4),session.getAttribute("loggedIn").toString()) == true)
	{
		session.setAttribute("update", "true");
		response.sendRedirect("../User/account.jsp");
	}
	else
	{
		session.setAttribute("update","false");
		response.sendRedirect("../User/account.jsp");
	}
}

%>
</body>
</html>